//
//  UIColor+Global.swift
//  DF_Student
//
//  Created by 刘盖 on 2023/12/9.
//  Copyright © 2023 DFJGED. All rights reserved.
//

import UIKit

@objc
public extension UIColor {
    
    @objc
    static let rgba: (_ r: CGFloat, _ g: CGFloat, _ b: CGFloat, _ a: CGFloat) -> UIColor = { r, g, b, a in
        return UIColor(red: r/255.0, green: g/255.0, blue: b/255.0, alpha: min(1, max(0, a)))
    }
    
    @objc
    static let rgb: (_ r: CGFloat, _ g: CGFloat, _ b: CGFloat) -> UIColor = { r, g, b in
        return UIColor(red: r/255.0, green: g/255.0, blue: b/255.0, alpha: 1)
    }
    
    @objc
    static let hex_a: (_ hex: Int, _ a: CGFloat) -> UIColor = { hex, a in
        return UIColor(red: CGFloat((hex & 0xFF0000) >> 16)/255.0, green: CGFloat((hex & 0xFF00) >> 8)/255.0, blue: CGFloat(hex & 0xFF)/255.0, alpha: min(1, max(0, a)))
    }
    
    @objc
    static let hex: (_ hex: Int) -> UIColor = { hex in
        return UIColor(red: CGFloat((hex & 0xFF0000) >> 16)/255.0, green: CGFloat((hex & 0xFF00) >> 8)/255.0, blue: CGFloat(hex & 0xFF)/255.0, alpha: 1)
    }
    
   
    @objc
    static var theme_black: UIColor {
        get {
            return self.rgba( 51, 51, 51, 1)
        }
    }
    
    @objc
    static var random_color: UIColor {
        return self.rgb(CGFloat(arc4random_uniform(255)), CGFloat(arc4random_uniform(255)), CGFloat(arc4random_uniform(255)))
    }
    
    @objc
    static let whiteAlpha: (_ alpha: CGFloat) -> UIColor = { alpha in
        return UIColor.rgba( 255, 255, 255, alpha)
    }
    
    
    @objc
    static var customRedColor: UIColor {
        return UIColor.rgb( 255, 87, 87)
    }
    
}
